home *** CD-ROM | disk | FTP | other *** search
/ Interactive Media Design Review 1999 / Interactive Media Design Review 1999.iso / pc / allfiles / Itch / work_info / WImage.dcr / 00006_Cherub Parent.ls < prev    next >
Encoding:
Text File  |  1999-03-07  |  3.8 KB  |  193 lines

  1. property sp, cst, pos, state, targetTimer, targetPoint, cherubPicList, lookDir, picTimer, pauseTimer, cherWingObj, weightObj
  2. global worldObj
  3.  
  4. on new me, asp
  5.   me.sp = asp
  6.   puppetSprite(me.sp, 1)
  7.   me.cst = the member of sprite me.sp
  8.   me.pos = the loc of sprite me.sp
  9.   cherWingObj = new(script("CherubWing Parent"), asp, pos)
  10.   weightObj = new(script("Weight Parent"), asp, pos)
  11.   cherubPicList = []
  12.   makeList(me, cherubPicList, "Cherub")
  13.   me.state = #normal
  14.   lookDir = 1
  15.   return me
  16. end
  17.  
  18. on ChecKHits me, aObj
  19.   if weightObj.state = #Drop then
  20.     tempList = GetCherubHitList(aObj, weightObj.sp)
  21.     if count(tempList) <> 0 then
  22.       GetHitStates(me, tempList)
  23.     end if
  24.   end if
  25. end
  26.  
  27. on GetHitStates me, aList
  28.   case getAt(aList, 2) of
  29.     #lever:
  30.       CuePauseTimer(me, 8)
  31.   end case
  32. end
  33.  
  34. on CheckState me
  35.   case me.state of
  36.     #normal:
  37.     #fly:
  38.       fly(me)
  39.       fly(cherWingObj)
  40.       RandomChangePic(me)
  41.     #released:
  42.       MoveUp(me)
  43.       fly(cherWingObj)
  44.     #end:
  45.       MoveUp(me)
  46.       fly(cherWingObj)
  47.   end case
  48. end
  49.  
  50. on SetWingWeightPos me, aPos
  51.   SetWingPos(cherWingObj, aPos)
  52.   setWeightPos(weightObj, aPos)
  53. end
  54.  
  55. on fly me
  56.   FixTargetPoint(me)
  57.   tempH = GetMoveHValue(me)
  58.   tempV = GetMoveVValue(me)
  59.   UpdatePos(me, point(tempH, tempV))
  60. end
  61.  
  62. on GetMoveHValue me
  63.   if me.pos.locH > targetPoint.locH then
  64.     tempH = random(3) * -1
  65.     return tempH
  66.   end if
  67.   if me.pos.locH < targetPoint.locH then
  68.     tempH = random(3)
  69.     return tempH
  70.   end if
  71. end
  72.  
  73. on GetMoveVValue me
  74.   if me.pos.locV > targetPoint.locV then
  75.     tempV = random(3) * -1
  76.     return tempV
  77.   end if
  78.   if me.pos.locV < targetPoint.locV then
  79.     tempV = random(3)
  80.     return tempV
  81.   end if
  82. end
  83.  
  84. on FixTargetPoint me
  85.   if the timer > targetTimer then
  86.     CueTargetTimer(me, random(500) + 200)
  87.     targetPoint = point(random(400) + 100, random(100) + 80)
  88.   end if
  89. end
  90.  
  91. on CueTargetTimer me, aNum
  92.   targetTimer = the timer + aNum
  93. end
  94.  
  95. on RandomChangePic me
  96.   if the timer > picTimer then
  97.     case lookDir of
  98.       1:
  99.         LookRightPic(me, cherubPicList)
  100.       2:
  101.         LookLeftPic(me, cherubPicList)
  102.       3:
  103.         SwapCast(me, member("Cherub2"))
  104.         CuePicTimer(me, random(80) + 20)
  105.     end case
  106.   end if
  107. end
  108.  
  109. on LookRightPic me, aList
  110.   tempPos = getOne(aList, me.cst)
  111.   if tempPos = count(aList) then
  112.     CuePicTimer(me, random(80) + 20)
  113.   else
  114.     SwapCast(me, getAt(aList, tempPos + 1))
  115.   end if
  116. end
  117.  
  118. on LookLeftPic me, aList
  119.   tempPos = getOne(aList, me.cst)
  120.   if tempPos = 1 then
  121.     CuePicTimer(me, random(80) + 20)
  122.   else
  123.     SwapCast(me, getAt(aList, tempPos - 1))
  124.   end if
  125. end
  126.  
  127. on CuePicTimer me, aNum
  128.   picTimer = the timer + aNum
  129.   lookDir = random(3)
  130. end
  131.  
  132. on MoveUp me
  133.   if me.pos.locV < (worldObj.worldRect.top - 100) then
  134.     me.state = #normal
  135.     weightObj.state = #stop
  136.   else
  137.     UpdatePos(me, point(0, -3))
  138.   end if
  139. end
  140.  
  141. on GetTarget me, asp
  142.   if asp = (me.sp + 2) then
  143.     MoveTarget(weightObj)
  144.     me.state = #released
  145.     return me
  146.   end if
  147. end
  148.  
  149. on makeList me, aList, aName
  150.   repeat with x = 1 to the maxinteger
  151.     if the number of member (aName & x) > 0 then
  152.       add(aList, member(aName & x))
  153.       next repeat
  154.     end if
  155.     exit repeat
  156.   end repeat
  157. end
  158.  
  159. on SwapCast me, aMem
  160.   me.cst = aMem
  161.   set the member of sprite the sp of me to me.cst
  162. end
  163.  
  164. on UpdatePos me, aPos
  165.   tempPos = me.pos + aPos
  166.   me.pos = tempPos
  167.   UpdatePos(cherWingObj, aPos)
  168.   CheckMyState(me, aPos)
  169. end
  170.  
  171. on CheckMyState me, aPos
  172.   case me.state of
  173.     #fly:
  174.       UpdatePos(weightObj, aPos)
  175.     #released:
  176.       if the timer > pauseTimer then
  177.         UpdatePos(weightObj, point(0, weightObj.speed))
  178.       end if
  179.     #end:
  180.       UpdatePos(weightObj, aPos)
  181.   end case
  182. end
  183.  
  184. on CuePauseTimer me, aNum
  185.   pauseTimer = the timer + aNum
  186. end
  187.  
  188. on DrawtoStage me
  189.   set the loc of sprite the sp of me to me.pos
  190.   DrawtoStage(cherWingObj)
  191.   DrawtoStage(weightObj)
  192. end
  193.